Skip to content

Commit

Permalink
Merge pull request #4 from zalando/use-github-actions
Browse files Browse the repository at this point in the history
Add github actions
  • Loading branch information
kostz authored Jan 9, 2025
2 parents e72287e + cdc72ce commit 1b1f8f6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Lightstep Receiver build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23.3
cache: false

- run: go install golang.org/x/lint/golint@latest
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

- name: Check
run: make check

- name: Build
run: make build

release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
needs: build
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get next version
uses: reecetech/[email protected]
id: version
with:
scheme: semver
increment: patch

- name: Create Tag and Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: v${{ steps.version.outputs.version }}
release_name: Release v${{ steps.version.outputs.version }}
draft: false
prerelease: false
11 changes: 9 additions & 2 deletions internal/lightstep_pb/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"io"
"net"
"net/http"
"sync"

lightstepCommon "github.com/zalando/otelcol-lightstep-receiver/internal/lightstep_common"
"github.com/zalando/otelcol-lightstep-receiver/internal/lightstep_pb"
Expand All @@ -37,6 +38,8 @@ type ServerHTTP struct {

nextTraces consumer.Traces
telemetry *telemetry.Telemetry

shutdownWG sync.WaitGroup
}

func NewServer(
Expand Down Expand Up @@ -64,18 +67,21 @@ func (s *ServerHTTP) Start(ctx context.Context, host component.Host) error {

ln, err = s.config.ToListener(ctx)
if err != nil {
return fmt.Errorf("can't init thrift server: %s", err)
return fmt.Errorf("can't init http pb server: %s", err)
}

rt := mux.NewRouter()
rt.HandleFunc("/api/v2/reports", s.HandleRequest).Methods(http.MethodPost)

s.server, err = s.config.ToServer(ctx, host, s.settings.TelemetrySettings, rt)
if err != nil {
return fmt.Errorf("can't start thrift http server %s", err)
return fmt.Errorf("can't start http pb server %s", err)
}

s.shutdownWG.Add(1)
go func() {
defer s.shutdownWG.Done()

if errHTTP := s.server.Serve(ln); !errors.Is(errHTTP, http.ErrServerClosed) && errHTTP != nil {
componentstatus.ReportStatus(host, componentstatus.NewFatalErrorEvent(errHTTP))
}
Expand All @@ -94,6 +100,7 @@ func (s *ServerHTTP) Shutdown(ctx context.Context) {
if err != nil {
s.telemetry.Logger.Error("failed to stop http pb server", zap.Error(err))
}
s.shutdownWG.Wait()
}
}

Expand Down
7 changes: 7 additions & 0 deletions internal/lightstep_thrift/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io"
"net"
"net/http"
"sync"

"github.com/zalando/otelcol-lightstep-receiver/internal/lightstep_thrift/thrift_0_9_2/lib/go/thrift"

Expand All @@ -40,6 +41,8 @@ type ThriftServer struct {

nextTraces consumer.Traces
telemetry *telemetry.Telemetry

shutdownWG sync.WaitGroup
}

func NewServer(
Expand Down Expand Up @@ -85,7 +88,10 @@ func (ts *ThriftServer) Start(ctx context.Context, host component.Host) error {
return fmt.Errorf("can't start thrift http server %s", err)
}

ts.shutdownWG.Add(1)
go func() {
defer ts.shutdownWG.Done()

if errHTTP := ts.server.Serve(ln); !errors.Is(errHTTP, http.ErrServerClosed) && errHTTP != nil {
componentstatus.ReportStatus(host, componentstatus.NewFatalErrorEvent(errHTTP))
}
Expand All @@ -104,6 +110,7 @@ func (ts *ThriftServer) Shutdown(ctx context.Context) {
if err != nil {
ts.telemetry.Logger.Error("failed to stop thrift server", zap.Error(err))
}
ts.shutdownWG.Wait()
}
}

Expand Down

0 comments on commit 1b1f8f6

Please sign in to comment.