Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0488097
feat: logs SDK observability - otlploggrpc exporter metrics
yumosx Sep 11, 2025
ac8f01a
commit all files
yumosx Sep 11, 2025
e017401
Merge remote-tracking branch 'upstream/main' into yumosx-observ-log-new
yumosx Sep 11, 2025
621e00f
update the go.mod
yumosx Sep 11, 2025
3921487
update pr id in readme.md
yumosx Sep 11, 2025
168f672
fix the missing comment
yumosx Sep 11, 2025
2b477de
Merge branch 'main' into yumosx-observ-log-new
yumosx Sep 11, 2025
751506d
rename the exportLogDone to exportLogsDone
yumosx Sep 11, 2025
58c1654
Merge remote-tracking branch 'origin/yumosx-observ-log-new' into yumo…
yumosx Sep 11, 2025
4d6167e
fix the name of the env and ajust the condation to observ
yumosx Sep 12, 2025
e864ee8
Reset component name counter for each test.
yumosx Sep 12, 2025
3b3d9ae
fix the version header and version value
yumosx Sep 12, 2025
a5ae93d
fix the version of the exportor
yumosx Sep 12, 2025
1027206
check code and fmt
yumosx Sep 12, 2025
8d70751
adjust the code of instrumentation and fix the missing name
yumosx Sep 16, 2025
916ab2a
Merge remote-tracking branch 'upstream/main' into yumosx-observ-log-new
yumosx Sep 16, 2025
f625ddf
fix the mod
yumosx Sep 16, 2025
4ec29e3
move it to other pr
yumosx Sep 16, 2025
1cc5eaf
add BenchmarkExporterExportLogs test
yumosx Sep 16, 2025
88d626c
adjust the code
yumosx Sep 17, 2025
fc8510e
fix the readme.md lint
yumosx Sep 17, 2025
9626db8
Merge remote-tracking branch 'upstream/main' into yumosx-observ-log-new
yumosx Sep 17, 2025
4d967e7
fix the readme.md
yumosx Sep 17, 2025
7966a52
Merge remote-tracking branch 'upstream/main' into yumosx-observ-log-new
yumosx Sep 19, 2025
8c3e4f7
adjust the code and fix the part success counter
yumosx Sep 19, 2025
dd99679
remove the repeated len(rl) and adjust the flag
yumosx Sep 19, 2025
05dade5
Merge remote-tracking branch 'upstream/main' into yumosx-observ-log-new
yumosx Sep 25, 2025
dc9a411
refactor: adjust the exportDone to exportOp and use the partialSuccess
yumosx Sep 25, 2025
6127c99
Merge remote-tracking branch 'upstream/main' into yumosx-observ-log-new
yumosx Sep 25, 2025
c4d7d8f
fix the benchmark bug
yumosx Sep 25, 2025
374d3da
adjust the name
yumosx Sep 25, 2025
d9ab178
rm unuse var
yumosx Sep 25, 2025
27b5970
add tests for the instrumentation scope
yumosx Sep 25, 2025
c42e1f7
fix documents and adjust the test use internal method
yumosx Sep 26, 2025
1140d03
replace defer to t.cleanup
yumosx Sep 26, 2025
6bb0d6b
fix the lint and check
yumosx Sep 26, 2025
436055a
Merge remote-tracking branch 'upstream/main' into yumosx-observ-log-new
yumosx Sep 29, 2025
da4a765
refactor the serverAddrAttrs
yumosx Sep 29, 2025
0be965f
Merge remote-tracking branch 'upstream/main' into yumosx-observ-log-new
yumosx Sep 29, 2025
32b3c7e
inner the counter package and fix the missing serverAddrAttrs logic
yumosx Sep 30, 2025
a57b09f
fix lint
yumosx Sep 30, 2025
f2b2f78
adjust the setExportID
yumosx Sep 30, 2025
b4b44ea
refactor done
yumosx Sep 30, 2025
607aff6
add debug log
yumosx Sep 30, 2025
e58aa63
fix the len
yumosx Sep 30, 2025
4d18315
make the nextExporterID unimport
yumosx Oct 1, 2025
45a461a
Merge branch 'main' into yumosx-observ-log-new
MrAlias Oct 2, 2025
a0d1b68
Merge branch 'main' into yumosx-observ-log-new
MrAlias Oct 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Greatly reduce the cost of recording metrics in `go.opentelemetry.io/otel/sdk/metric` using hashing for map keys. (#7175)
- Add experimental observability for the prometheus exporter in `go.opentelemetry.io/otel/exporters/prometheus`.
Check the `go.opentelemetry.io/otel/exporters/prometheus/internal/x` package documentation for more information. (#7345)
- Add experimental observability metrics in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`. (#7353)

### Fixed

Expand Down
38 changes: 18 additions & 20 deletions exporters/otlp/otlplog/otlploggrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package otlploggrpc // import "go.opentelemetry.io/otel/exporters/otlp/otlplog/o
import (
"context"
"errors"
"fmt"
"time"

collogpb "go.opentelemetry.io/proto/otlp/collector/logs/v1"
Expand All @@ -21,6 +20,9 @@ import (
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"

"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal"
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal/counter"
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal/observ"
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal/retry"
)

Expand All @@ -37,6 +39,8 @@ type client struct {
ourConn bool
conn *grpc.ClientConn
lsc collogpb.LogsServiceClient

instrumentation *observ.Instrumentation
}

// Used for testing.
Expand Down Expand Up @@ -71,7 +75,10 @@ func newClient(cfg config) (*client, error) {

c.lsc = collogpb.NewLogsServiceClient(c.conn)

return c, nil
var err error
id := counter.NextExporterID()
c.instrumentation, err = observ.NewInstrumentation(id, c.conn.CanonicalTarget())
return c, err
}

func newGRPCDialOptions(cfg config) []grpc.DialOption {
Expand Down Expand Up @@ -131,6 +138,14 @@ func (c *client) UploadLogs(ctx context.Context, rl []*logpb.ResourceLogs) (uplo
ctx, cancel := c.exportContext(ctx)
defer cancel()

count := int64(len(rl))
if c.instrumentation != nil {
eo := c.instrumentation.ExportLogs(ctx, count)
defer func() {
eo.End(uploadErr)
}()
}

return errors.Join(uploadErr, c.requestFunc(ctx, func(ctx context.Context) error {
resp, err := c.lsc.Export(ctx, &collogpb.ExportLogsServiceRequest{
ResourceLogs: rl,
Expand All @@ -139,7 +154,7 @@ func (c *client) UploadLogs(ctx context.Context, rl []*logpb.ResourceLogs) (uplo
msg := resp.PartialSuccess.GetErrorMessage()
n := resp.PartialSuccess.GetRejectedLogRecords()
if n != 0 || msg != "" {
err := errPartial{msg: msg, n: n}
err := internal.LogPartialSuccessError(n, msg)
uploadErr = errors.Join(uploadErr, err)
}
}
Expand All @@ -152,23 +167,6 @@ func (c *client) UploadLogs(ctx context.Context, rl []*logpb.ResourceLogs) (uplo
}))
}

type errPartial struct {
msg string
n int64
}

var _ error = errPartial{}

func (e errPartial) Error() string {
const form = "OTLP partial success: %s (%d log records rejected)"
return fmt.Sprintf(form, e.msg, e.n)
}

func (errPartial) Is(target error) bool {
_, ok := target.(errPartial)
return ok
}

// Shutdown shuts down the client, freeing all resources.
//
// Any active connections to a remote endpoint are closed if they were created
Expand Down
Loading
Loading