Skip to content

Commit

Permalink
Merge branch 'main' into typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Aneurysm9 authored Aug 30, 2021
2 parents 695ab62 + abf6afe commit 3fdbd1a
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 177 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v2.1.4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v2.1.4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
Expand All @@ -71,7 +71,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v2.1.4
with:
go-version: ${{ env.DEFAULT_GO_VERSION }}
- name: Checkout Repo
Expand All @@ -95,7 +95,7 @@ jobs:
cp coverage.txt $TEST_RESULTS
cp coverage.html $TEST_RESULTS
- name: Upload coverage report
uses: codecov/codecov-action@v2.0.2
uses: codecov/codecov-action@v2.0.3
with:
file: ./coverage.txt
fail_ci_if_error: true
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v2.1.4
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-go@v2
- uses: actions/setup-go@v2.1.4
with:
go-version: '^1.15.0'
- uses: evantorrie/mott-the-tidier@v1-beta
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Metric SDK/API implementation type `InstrumentKind` moves into `sdkapi` sub-package. (#2091)
- The Metrics SDK export record no longer contains a Resource pointer, the SDK `"go.opentelemetry.io/otel/sdk/trace/export/metric".Exporter.Export()` function for push-based exporters now takes a single Resource argument, pull-based exporters use `"go.opentelemetry.io/otel/sdk/metric/controller/basic".Controller.Resource()`. (#2120)
- The JSON output of the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace` is harmonized now such that the output is "plain" JSON objects after each other of the form `{ ... } { ... } { ... }`. Earlier the JSON objects describing a span were wrapped in a slice for each `Exporter.ExportSpans` call, like `[ { ... } ][ { ... } { ... } ]`. Outputting JSON object directly after each other is consistent with JSON loggers, and a bit easier to parse and read. (#2196)

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion example/otel-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ need to create the Jaeger and Prometheus exporters:
```yml
...
exporters:
jaeger_grpc:
jaeger:
endpoint: "jaeger-collector.observability.svc.cluster.local:14250"

prometheus:
Expand Down
38 changes: 0 additions & 38 deletions exporters/stdout/stdouttrace/exporter.go

This file was deleted.

58 changes: 36 additions & 22 deletions exporters/stdout/stdouttrace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package stdouttrace // import "go.opentelemetry.io/otel/exporters/stdout/stdoutt
import (
"context"
"encoding/json"
"fmt"
"sync"
"time"

Expand All @@ -27,16 +26,37 @@ import (

var zeroTime time.Time

var _ trace.SpanExporter = &Exporter{}

// New creates an Exporter with the passed options.
func New(options ...Option) (*Exporter, error) {
cfg, err := newConfig(options...)
if err != nil {
return nil, err
}

enc := json.NewEncoder(cfg.Writer)
if cfg.PrettyPrint {
enc.SetIndent("", "\t")
}

return &Exporter{
encoder: enc,
timestamps: cfg.Timestamps,
}, nil
}

// Exporter is an implementation of trace.SpanSyncer that writes spans to stdout.
type traceExporter struct {
config config
type Exporter struct {
encoder *json.Encoder
timestamps bool

stoppedMu sync.RWMutex
stopped bool
}

// ExportSpans writes spans in json format to stdout.
func (e *traceExporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan) error {
func (e *Exporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan) error {
e.stoppedMu.RLock()
stopped := e.stopped
e.stoppedMu.RUnlock()
Expand All @@ -47,29 +67,31 @@ func (e *traceExporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlyS
if len(spans) == 0 {
return nil
}

stubs := tracetest.SpanStubsFromReadOnlySpans(spans)
if !e.config.Timestamps {
for i := range stubs {
stub := &stubs[i]

for i := range stubs {
stub := &stubs[i]
// Remove timestamps
if !e.timestamps {
stub.StartTime = zeroTime
stub.EndTime = zeroTime
for j := range stub.Events {
ev := &stub.Events[j]
ev.Time = zeroTime
}
}
}

out, err := e.marshal(stubs)
if err != nil {
return err
// Encode span stubs, one by one
if err := e.encoder.Encode(stub); err != nil {
return err
}
}
_, err = fmt.Fprintln(e.config.Writer, string(out))
return err
return nil
}

// Shutdown is called to stop the exporter, it preforms no action.
func (e *traceExporter) Shutdown(ctx context.Context) error {
func (e *Exporter) Shutdown(ctx context.Context) error {
e.stoppedMu.Lock()
e.stopped = true
e.stoppedMu.Unlock()
Expand All @@ -81,11 +103,3 @@ func (e *traceExporter) Shutdown(ctx context.Context) error {
}
return nil
}

// marshal v with approriate indentation.
func (e *traceExporter) marshal(v interface{}) ([]byte, error) {
if e.config.PrettyPrint {
return json.MarshalIndent(v, "", "\t")
}
return json.Marshal(v)
}
Loading

0 comments on commit 3fdbd1a

Please sign in to comment.