Skip to content
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
merged 5 commits into from
Aug 23, 2024

Conversation

zmoog
Copy link
Contributor

@zmoog zmoog commented Aug 7, 2024

Proposed commit message

Add a tracer for the github.com/devigned/tab package to route logs from the legacy event hub SDK to the logp package.

The legacy event hub SDK uses the github.com/devigned/tab package to handle traces and logs.

However, this package is old and seems unmaintained (last commit: 3 years ago). Since it only supports OpenTracing or OpenCensus, in Beats, the library defaults to a NoOpTracer, so we don’t see anything happening inside the legacy processor.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

I don't expect the trace to impact users or other Beats components. It seems the legacy event hub SDK is the only dependency using this old package:

$ go mod why -m github.com/devigned/tab

# github.com/devigned/tab
github.com/elastic/beats/v7/x-pack/filebeat/input/azureeventhub
github.com/Azure/azure-event-hubs-go/v3
github.com/devigned/tab

Related issues

Logs

Start Filebeat using a valid azure-eventhub config, and you will be able to read the log messages from the processor and the leaser/checkpointer components:

$ pbpaste | grep '^{' | jq -r 'select(."log.origin"."file.name" == "azureeventhub/tracer.go") | [."@timestamp",."log.level",.message] | @tsv'

2024-08-07T16:17:12.305+0200	debug	successful rpc on link 494e91ef-8e06-4460-b89b-361d44c64f75: status code 200 and description:
2024-08-07T16:17:17.306+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb": running scan
2024-08-07T16:17:19.667+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb": acquired: [{"partitionID":"1","epoch":21,"owner":"86edc94f-dd34-44d3-8a43-ecf3cf4c77fb","checkpoint":{"offset":"201863710488","sequenceNumber":8568,"enqueueTime":"2024-08-07T13:35:51.837Z"},"state":"available","token":"32ab10ca-cc08-42a8-83fd-1dc436f25abc"} {"partitionID":"0","epoch":23,"owner":"86edc94f-dd34-44d3-8a43-ecf3cf4c77fb","checkpoint":{"offset":"206158444904","sequenceNumber":8565,"enqueueTime":"2024-08-07T13:26:15.225Z"},"state":"available","token":"e4aa4ecd-ab0f-4984-92cd-a4c6dbcfa433"}], not acquired: []
2024-08-07T16:17:19.667+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb", partition "1", epoch 21: running...
2024-08-07T16:17:19.667+0200	debug	creating a new receiver
2024-08-07T16:17:21.349+0200	debug	negotiating claim for audience amqps://mbranca-general.servicebus.windows.net/activitylogs/ConsumerGroups/$Default/Partitions/1 with token type servicebus.windows.net:sastoken and expiry of 1723047441
2024-08-07T16:17:21.562+0200	debug	successful rpc on link 3f9e7e50-f012-4692-8172-8b8d5c9dde17: status code 202 and description: Accepted
2024-08-07T16:17:21.563+0200	debug	negotiated with response code 202 and message: Accepted
2024-08-07T16:17:22.293+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb", partition "0", epoch 23: running...
2024-08-07T16:17:22.293+0200	debug	creating a new receiver
2024-08-07T16:17:24.705+0200	debug	negotiating claim for audience amqps://mbranca-general.servicebus.windows.net/activitylogs/ConsumerGroups/$Default/Partitions/0 with token type servicebus.windows.net:sastoken and expiry of 1723047445
2024-08-07T16:17:25.013+0200	debug	successful rpc on link 6bb4086b-b8ae-46ca-87dc-ef4e18c15db2: status code 202 and description: Accepted
2024-08-07T16:17:25.013+0200	debug	negotiated with response code 202 and message: Accepted
2024-08-07T16:17:30.261+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb", partition "1", epoch 21: lease renewed
2024-08-07T16:17:32.620+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb", partition "0", epoch 23: lease renewed
2024-08-07T16:17:35.807+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb": running scan
2024-08-07T16:17:36.566+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb": acquired: [], not acquired: [{"partitionID":"0","epoch":23,"owner":"86edc94f-dd34-44d3-8a43-ecf3cf4c77fb","checkpoint":{"offset":"206158444904","sequenceNumber":8565,"enqueueTime":"2024-08-07T13:26:15.225Z"},"state":"leased","token":"e4aa4ecd-ab0f-4984-92cd-a4c6dbcfa433"} {"partitionID":"1","epoch":21,"owner":"86edc94f-dd34-44d3-8a43-ecf3cf4c77fb","checkpoint":{"offset":"201863710488","sequenceNumber":8568,"enqueueTime":"2024-08-07T13:35:51.837Z"},"state":"leased","token":"32ab10ca-cc08-42a8-83fd-1dc436f25abc"}]
2024-08-07T16:17:43.233+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb", partition "0", epoch 23: lease renewed
2024-08-07T16:17:46.407+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb": running scan
2024-08-07T16:17:47.382+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb": acquired: [], not acquired: [{"partitionID":"0","epoch":23,"owner":"86edc94f-dd34-44d3-8a43-ecf3cf4c77fb","checkpoint":{"offset":"206158444904","sequenceNumber":8565,"enqueueTime":"2024-08-07T13:26:15.225Z"},"state":"leased","token":"e4aa4ecd-ab0f-4984-92cd-a4c6dbcfa433"} {"partitionID":"1","epoch":21,"owner":"86edc94f-dd34-44d3-8a43-ecf3cf4c77fb","checkpoint":{"offset":"201863710488","sequenceNumber":8568,"enqueueTime":"2024-08-07T13:35:51.837Z"},"state":"leased","token":"32ab10ca-cc08-42a8-83fd-1dc436f25abc"}]
2024-08-07T16:17:50.100+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb", partition "1", epoch 21: lease renewed
2024-08-07T16:17:52.965+0200	debug	eph "86edc94f-dd34-44d3-8a43-ecf3cf4c77fb", partition "0", epoch 23: lease renewed

The tracer and spanner from github.com/devigned/tab only route logs
to the logp package.
@zmoog zmoog self-assigned this Aug 7, 2024
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Aug 7, 2024
@zmoog zmoog added enhancement Team:obs-ds-hosted-services Label for the Observability Hosted Services team input:azure-eventhub and removed needs_team Indicates that the issue/PR needs a Team:* label labels Aug 7, 2024
Copy link
Contributor

mergify bot commented Aug 7, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @zmoog? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@zmoog zmoog marked this pull request as ready for review August 7, 2024 15:54
@zmoog zmoog requested review from a team as code owners August 7, 2024 15:54
@zmoog zmoog requested review from AndersonQ and rdner August 7, 2024 15:54
@elasticmachine
Copy link
Collaborator

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Aug 8, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@pierrehilbert pierrehilbert requested a review from faec August 8, 2024 07:00
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng left a comment

Choose a reason for hiding this comment

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

Looks like this tracer will fill the gap on missing sdk logs for azure. I think it's worth to add. Are you planning to backport it to other versions to help debugging?

Comment on lines +100 to +115
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) {
Copy link
Member

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 to logp

Copy link
Contributor Author

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 and logsOnlySpanner implementations, the attributes are nil:

CleanShot 2024-08-13 at 15 04 44@2x

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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

Copy link
Member

@cmacknz cmacknz left a comment

Choose a reason for hiding this comment

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

Approving go.mod changes.

@zmoog zmoog added the backport-8.15 Automated backport to the 8.15 branch with mergify label Aug 22, 2024
@zmoog zmoog merged commit e64ea44 into elastic:main Aug 23, 2024
121 checks passed
@zmoog zmoog deleted the zmoog/bridge-eventhub-sdk-logging-to-logp branch August 23, 2024 13:38
mergify bot pushed a commit that referenced this pull request Aug 23, 2024
Add a tracer for the github.com/devigned/tab package to route logs from the legacy event hub SDK to the logp package.

The legacy event hub SDK uses the [github.com/devigned/tab](http://github.com/devigned/tab) package to handle traces and logs.

However, this package is old and seems unmaintained (last commit: 3 years ago). Since it only supports OpenTracing or OpenCensus, in Beats, the library defaults to a `NoOpTracer`, so we don’t see anything happening inside the legacy processor.

(cherry picked from commit e64ea44)

# Conflicts:
#	NOTICE.txt
zmoog added a commit that referenced this pull request Aug 23, 2024
… SDK logs to logp (#40603)

* Add a tracer to send (legacy) Azure Event Hub SDK logs to logp (#40451)

Add a tracer for the github.com/devigned/tab package to route logs from the legacy event hub SDK to the logp package.

The legacy event hub SDK uses the [github.com/devigned/tab](http://github.com/devigned/tab) package to handle traces and logs.

However, this package is old and seems unmaintained (last commit: 3 years ago). Since it only supports OpenTracing or OpenCensus, in Beats, the library defaults to a `NoOpTracer`, so we don’t see anything happening inside the legacy processor.

---------

Co-authored-by: Maurizio Branca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.15 Automated backport to the 8.15 branch with mergify enhancement input:azure-eventhub Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:obs-ds-hosted-services Label for the Observability Hosted Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Filebeat] Bridge legacy Event Hub SDK logs to logp
7 participants