-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: logs SDK observability - otlploggrpc exporter metrics #7084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7084 +/- ##
======================================
Coverage 82.9% 82.9%
======================================
Files 262 263 +1
Lines 24460 24597 +137
======================================
+ Hits 20281 20395 +114
- Misses 3801 3819 +18
- Partials 378 383 +5
🚀 New features to boost your workflow:
|
@@ -19,12 +22,28 @@ import ( | |||
"google.golang.org/grpc/metadata" | |||
"google.golang.org/grpc/status" | |||
|
|||
"go.opentelemetry.io/otel/attribute" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank lines, they need to be grouped together.
if resp != nil && resp.PartialSuccess != nil { | ||
msg := resp.PartialSuccess.GetErrorMessage() | ||
n := resp.PartialSuccess.GetRejectedLogRecords() | ||
if n != 0 || msg != "" { | ||
err := fmt.Errorf("OTLP partial success: %s (%d log records rejected)", msg, n) | ||
c.recordLogInflightMetric(ctx, attribute.String("error.type", err.Error())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx
like these should, in theory, be detached from the contextual background.
Temporarily marked as an interrogative stance.
Good suggestion, done. |
collogpb "go.opentelemetry.io/proto/otlp/collector/logs/v1" | ||
logpb "go.opentelemetry.io/proto/otlp/logs/v1" | ||
) | ||
|
||
var ( | ||
componentType = otelconv.ComponentTypeOtlpGRPCLogExporter | ||
exporterInstanceCounter int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it would be safer to use atomic.Int64 directly here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, this is my oversight. I'll fix it.
if resp != nil && resp.PartialSuccess != nil { | ||
msg := resp.PartialSuccess.GetErrorMessage() | ||
n := resp.PartialSuccess.GetRejectedLogRecords() | ||
if n != 0 || msg != "" { | ||
err := fmt.Errorf("OTLP partial success: %s (%d log records rejected)", msg, n) | ||
c.recordLogInflightMetric(context.Background(), attribute.String("error.type", err.Error())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, error type is supposed to be one of a specific set of errors to prevent cardinality explosion. See https://github.com/open-telemetry/opentelemetry-go-contrib/blob/e09bd7c580cdc6bc48e9da8ac832665e5a2ce314/instrumentation/net/http/otelhttp/internal/semconv/httpconv.go#L411 for an example of what otelhttp does.
c.logExportedDurationMetric.Record(ctx, duration, attrs...) | ||
} | ||
|
||
func (c *client) getPort() int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we compute this on client initialization so we don't need to do it each time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
- use atomic.Int64 - use ErrorType
fix #7019