Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ed73a66
add the otlplogrpc selfObservaility
yumosx Jul 24, 2025
4aa0a5b
merge upstream
yumosx Jul 24, 2025
87f64f3
Add self-observability support for otlplog grpc exporter
yumosx Jul 25, 2025
bd9de33
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Jul 25, 2025
56be45b
commit
yumosx Jul 25, 2025
2961556
add x_test.go and update selfObsever
yumosx Jul 25, 2025
97a7d77
- compute post on initialization
yumosx Jul 25, 2025
030120c
fix the data race
yumosx Jul 25, 2025
0c7a55b
updated
yumosx Jul 26, 2025
be6242e
add changlog entry and readme.md
yumosx Jul 28, 2025
7c31573
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Jul 28, 2025
2e1da4a
fix spell
yumosx Jul 28, 2025
d228db8
add the error tests
yumosx Jul 28, 2025
7a41831
improve error handling
yumosx Jul 28, 2025
6797188
refactor
yumosx Jul 29, 2025
caea157
rename filed
yumosx Jul 29, 2025
76baec3
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Jul 29, 2025
35f9291
fix some errors in the document, renamed the grpcExporterCounter and fix
yumosx Jul 30, 2025
4cbf661
remove space
yumosx Jul 30, 2025
71b55e0
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Jul 30, 2025
966afed
use equalFlod
yumosx Jul 30, 2025
49531d2
fix data race of counter
yumosx Jul 30, 2025
e0bb5f7
updated
yumosx Jul 30, 2025
57ec779
refactor: pre-allocate
yumosx Jul 31, 2025
95008b1
feat: Use defer to record the duration of Export calls
yumosx Jul 31, 2025
1f31142
resolve conflicts
yumosx Aug 4, 2025
9b63d1a
correctly identify and strip the scheme (e.g., `dns://`, `unix://`).
yumosx Aug 4, 2025
f65b074
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Aug 4, 2025
6abf099
refactor(otlploggrpc): Extract all exporter metrics recording code f…
yumosx Aug 5, 2025
2f3ec93
fix lint
yumosx Aug 5, 2025
289c387
fix(metrics): use log count in metric
yumosx Aug 6, 2025
0f99a18
merge
yumosx Aug 6, 2025
b5c565b
rm the duplicate definition
yumosx Aug 6, 2025
1171c15
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Aug 8, 2025
9802efc
use loacl attrs and added the test for initselfobservability
yumosx Aug 9, 2025
b95c65f
fix conflicts
yumosx Aug 9, 2025
c77c785
Fix the issue of repeated exports.
yumosx Aug 11, 2025
86a3074
move the trackExportfunc to outside
yumosx Aug 12, 2025
2ce12c0
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Aug 12, 2025
159c0c1
fix conflicts
yumosx Aug 12, 2025
921f390
refactor(selfobservability): improve server address parsing and track…
yumosx Aug 18, 2025
391cef4
merge
yumosx Aug 18, 2025
33cf67c
Restructure component ID counting
yumosx Aug 18, 2025
a9f1fc2
merge upstream
yumosx Aug 18, 2025
a027878
fix changelog
yumosx Aug 18, 2025
cc2d577
refactor(metrics): add missing error export counter for partial success
yumosx Aug 20, 2025
cc0f0d9
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Aug 20, 2025
65776ba
fix the NewExporterMetrics and add test
yumosx Aug 20, 2025
147363c
fmt code
yumosx Aug 20, 2025
d9e8dff
refactor: avoid assigning presetAttrs when metric initialization fails
yumosx Aug 20, 2025
4bbfed0
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Aug 26, 2025
0b0f411
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Aug 27, 2025
a32dd6e
perf: use addSet instead of add for better performance
yumosx Aug 28, 2025
1736a9e
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Aug 28, 2025
b778294
fix the missing tests
yumosx Aug 28, 2025
947bf9c
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Sep 9, 2025
ef06e5d
update go mod
yumosx Sep 9, 2025
eb8493a
refactor(self-observability): align code with style guide
yumosx Sep 10, 2025
16eaf3c
fix the changlog check
yumosx Sep 10, 2025
74033bc
refactor: rename the selfoberv to observ and direct use the inst
yumosx Sep 10, 2025
1569d2b
Merge remote-tracking branch 'upstream/main' into yumosx-self-mlog
yumosx Sep 10, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Comment thread
yumosx marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

- Add `WithInstrumentationAttributeSet` option to `go.opentelemetry.io/otel/log`, `go.opentelemetry.io/otel/metric`, and `go.opentelemetry.io/otel/trace` packages.
This provides a concurrent-safe and performant alternative to `WithInstrumentationAttributes` by accepting a pre-constructed `attribute.Set`. (#7287)
- - Add experimental self-observability metrics in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- - Add experimental self-observability metrics in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`.
- Add experimental self-observability metrics in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`.

Check the `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal/x` package documentation for more information. (#7084)

### Fixed

Expand Down
45 changes: 41 additions & 4 deletions exporters/otlp/otlplog/otlploggrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import (
"google.golang.org/grpc/status"

"go.opentelemetry.io/otel"
"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"
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal/x"
"go.opentelemetry.io/otel/semconv/v1.37.0/otelconv"
)

// The methods of this type are not expected to be called concurrently.
Expand All @@ -38,6 +42,8 @@ type client struct {
ourConn bool
conn *grpc.ClientConn
lsc collogpb.LogsServiceClient

instrumentation *observ.Instrumentation
}

// Used for testing.
Expand Down Expand Up @@ -72,7 +78,20 @@ func newClient(cfg config) (*client, error) {

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

return c, nil
if !x.SelfObservability.Enabled() {
return c, nil
}

id := counter.NextExporterID()
componentName := fmt.Sprintf("%s/%d", otelconv.ComponentTypeOtlpGRPCLogExporter, id)
var err error
c.instrumentation, err = observ.NewInstrumentation(
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc",
componentName,
otelconv.ComponentTypeOtlpGRPCLogExporter,
c.conn.CanonicalTarget(),
)
return c, err
}

func newGRPCDialOptions(cfg config) []grpc.DialOption {
Expand Down Expand Up @@ -121,7 +140,7 @@ func newGRPCDialOptions(cfg config) []grpc.DialOption {
// The otlplog.Exporter synchronizes access to client methods, and
// ensures this is not called after the Exporter is shutdown. Only thing
// to do here is send data.
func (c *client) UploadLogs(ctx context.Context, rl []*logpb.ResourceLogs) error {
func (c *client) UploadLogs(ctx context.Context, rl []*logpb.ResourceLogs) (err error) {
select {
case <-ctx.Done():
// Do not upload if the context is already expired.
Expand All @@ -132,23 +151,41 @@ func (c *client) UploadLogs(ctx context.Context, rl []*logpb.ResourceLogs) error
ctx, cancel := c.exportContext(ctx)
defer cancel()

success := int64(len(rl))
// partialSuccessErr records an error when the export is partially successful.
var partialSuccessErr error
if c.instrumentation != nil {
count := len(rl)
trackExportFunc := c.instrumentation.ExportSpans(ctx, int64(count))
defer func() {
if partialSuccessErr != nil {
trackExportFunc(partialSuccessErr, success, status.Code(partialSuccessErr))
return
}
trackExportFunc(err, success, status.Code(err))
}()
}

return c.requestFunc(ctx, func(ctx context.Context) error {
resp, err := c.lsc.Export(ctx, &collogpb.ExportLogsServiceRequest{
ResourceLogs: rl,
})

if resp != nil && resp.PartialSuccess != nil {
msg := resp.PartialSuccess.GetErrorMessage()
n := resp.PartialSuccess.GetRejectedLogRecords()
success -= n
if n != 0 || msg != "" {
err := fmt.Errorf("OTLP partial success: %s (%d log records rejected)", msg, n)
otel.Handle(err)
partialSuccessErr = fmt.Errorf("OTLP partial success: %s (%d log records rejected)", msg, n)
otel.Handle(partialSuccessErr)
}
}
// nil is converted to OK.
if status.Code(err) == codes.OK {
// Success.
return nil
}
success = 0
return err
})
}
Expand Down
Loading
Loading