-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add a tracer to send (legacy) Azure Event Hub SDK logs to logp #40451
Merged
zmoog
merged 5 commits into
elastic:main
from
zmoog:zmoog/bridge-eventhub-sdk-logging-to-logp
Aug 23, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10907,6 +10907,37 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
Dependency : github.com/devigned/tab | ||
Version: v0.1.2-0.20190607222403-0c15cf42f9a2 | ||
Licence type (autodetected): MIT | ||
-------------------------------------------------------------------------------- | ||
|
||
Contents of probable licence file $GOMODCACHE/github.com/devigned/[email protected]/LICENSE: | ||
|
||
MIT License | ||
|
||
Copyright (c) 2019 David Justice | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
Dependency : github.com/dgraph-io/badger/v3 | ||
Version: v3.2103.1 | ||
|
@@ -37209,37 +37240,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
Dependency : github.com/devigned/tab | ||
Version: v0.1.2-0.20190607222403-0c15cf42f9a2 | ||
Licence type (autodetected): MIT | ||
-------------------------------------------------------------------------------- | ||
|
||
Contents of probable licence file $GOMODCACHE/github.com/devigned/[email protected]/LICENSE: | ||
|
||
MIT License | ||
|
||
Copyright (c) 2019 David Justice | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
Dependency : github.com/elastic/ristretto | ||
Version: v0.1.1-0.20220602190459-83b0895ca5b3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
//go:build !aix | ||
|
||
package azureeventhub | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/devigned/tab" | ||
|
||
"github.com/elastic/elastic-agent-libs/logp" | ||
) | ||
|
||
func init() { | ||
tab.Register(new(logsOnlyTracer)) | ||
} | ||
|
||
// logsOnlyTracer manages the creation of the required | ||
// Spanners and Loggers with the goal of deferring logging | ||
// to the `logp` package. | ||
// | ||
// According to the `github.com/devigned/tab package`, | ||
// to implement a Tracer, you must provide the following | ||
// three components: | ||
// | ||
// - Tracer | ||
// - Spanner | ||
// - Logger | ||
// | ||
// Since we are currently only interested in logging, we will | ||
// implement a Tracer that only logs. | ||
type logsOnlyTracer struct{} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Tracer | ||
// ---------------------------------------------------------------------------- | ||
|
||
// StartSpan returns the input context and a no-op Spanner | ||
func (nt *logsOnlyTracer) StartSpan(ctx context.Context, operationName string, opts ...interface{}) (context.Context, tab.Spanner) { | ||
return ctx, new(logsOnlySpanner) | ||
} | ||
|
||
// StartSpanWithRemoteParent returns the input context and a no-op Spanner | ||
func (nt *logsOnlyTracer) StartSpanWithRemoteParent(ctx context.Context, operationName string, carrier tab.Carrier, opts ...interface{}) (context.Context, tab.Spanner) { | ||
return ctx, new(logsOnlySpanner) | ||
} | ||
|
||
// FromContext returns a no-op Spanner without regard to the input context | ||
func (nt *logsOnlyTracer) FromContext(ctx context.Context) tab.Spanner { | ||
return new(logsOnlySpanner) | ||
} | ||
|
||
// NewContext returns the parent context | ||
func (nt *logsOnlyTracer) NewContext(parent context.Context, span tab.Spanner) context.Context { | ||
return parent | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Spanner | ||
// ---------------------------------------------------------------------------- | ||
|
||
// logsOnlySpanner is a Spanner implementation that focuses | ||
// on logging only. | ||
type logsOnlySpanner struct{} | ||
|
||
// AddAttributes is a no-op | ||
func (ns *logsOnlySpanner) AddAttributes(attributes ...tab.Attribute) {} | ||
|
||
// End is a no-op | ||
func (ns *logsOnlySpanner) End() {} | ||
|
||
// Logger returns a Logger implementation | ||
func (ns *logsOnlySpanner) Logger() tab.Logger { | ||
return &logpLogger{logp.L()} | ||
} | ||
|
||
// Inject is no-op | ||
func (ns *logsOnlySpanner) Inject(carrier tab.Carrier) error { | ||
return nil | ||
} | ||
|
||
// InternalSpan returns nil | ||
func (ns *logsOnlySpanner) InternalSpan() interface{} { | ||
return nil | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Logger | ||
// ---------------------------------------------------------------------------- | ||
|
||
// logpLogger defers logging to the logp package | ||
type logpLogger struct { | ||
logger *logp.Logger | ||
} | ||
|
||
// Info logs a message at info level | ||
func (sl logpLogger) Info(msg string, attributes ...tab.Attribute) { | ||
sl.logger.Info(msg) | ||
} | ||
|
||
// Error logs a message at error level | ||
func (sl logpLogger) Error(err error, attributes ...tab.Attribute) { | ||
sl.logger.Error(err) | ||
} | ||
|
||
// Fatal logs a message at Fatal level | ||
func (sl logpLogger) Fatal(msg string, attributes ...tab.Attribute) { | ||
sl.logger.Fatal(msg) | ||
} | ||
|
||
// Debug logs a message at Debug level | ||
func (sl logpLogger) Debug(msg string, attributes ...tab.Attribute) { | ||
sl.logger.Debug(msg) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[Blocker]
Why are the attributes ignored?
you could use the
w
functions to pass the attributes tologp
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.
With the current simple and log-focused
logsOnlyTracer
andlogsOnlySpanner
implementations, the attributes arenil
:I am targeting 8.15.1 to ship at least the logs because, as of today, we have literally zero visibility into the legacy SDK's inner workings. The logs would be pure gold in a couple of SDHs I am working on.
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.
I aim to bridge the legacy SDK logs into
logp
so they will be available in a diagnostics bundle.I would love to have traces and spans. However, logs alone bring 80% of the value, and they seem achievable in the 8.15.1 FF time frame.
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.
@AndersonQ, do you think it's okay to ship this logging solution in time for 8.15.1 (this could help in troubleshooting a lot) and invest more in tracing for input v1 and v2 for 8.15.2 and 8.16?
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.
well, something is better than nothing, even thought I still believe the effort to add the attributes is marginal, I won't block the PR.
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.
but it'd appreciate a followup PR logging the attributes as well