Skip to content

Conversation

@isaacaflores2
Copy link
Contributor

@isaacaflores2 isaacaflores2 commented Dec 2, 2025

Overview

  • Add the ability to set the host.ip resource attribute value using the client address from ctx.Client.Info.Addr
    • The enrichment is controlled via the host_ip_enabled config
  • I opted to add the enrich here versus in the opentelemetry-lib enricher since the enrich methods do not accept a ctx.

Edit: I forgot to add that I am working on an upstream issue open-telemetry/opentelemetry-collector#14186 that will provide more flexibility on how the ctx.Client.Info.Addr` is set.

Edit: The ctx.Client.Info.Addr manipulation will now be implemented as a middleware extension: #930 #936

Misc updates

  • Add missing log and metric test cases to TestProcessorECS

@isaacaflores2 isaacaflores2 requested review from a team as code owners December 2, 2025 21:40
@isaacaflores2 isaacaflores2 marked this pull request as draft December 2, 2025 21:40
@isaacaflores2 isaacaflores2 changed the title [processor/elasticapm] Processor host ip [processor/elasticapm] Add host.ip enrichment using the client info address Dec 2, 2025
@isaacaflores2 isaacaflores2 marked this pull request as ready for review December 2, 2025 21:59
Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

Have we thought about how this enrichment would work when using this processor in the EDOT gateway?

// HostIPEnabled controls whether the `host.ip` resource attribute should be set using client info address.
// When true, the processor will set the `host.ip` attribute from the client address when
// the mapping mode is "ecs". Defaults to true.
HostIPEnabled bool `mapstructure:"host_ip_enabled"`
Copy link
Member

Choose a reason for hiding this comment

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

Whats the reasoning behind doing this via a flag vs adding it by default if the Client address exists?

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 added the config since I thought users may not/need this new field and to align with the existing approach in the opentelemtry-lib config where each field enrichment is behind a config.

@inge4pres
Copy link
Contributor

Have we thought about how this enrichment would work when using this processor in the EDOT gateway?

@vigneshshanmugam good point 👍🏼 I guess this is the reason for which Isaac decided to introduce a flag to add the filed.
Are you aware of any implications?
Should we reach out to someone to validate?

@vigneshshanmugam
Copy link
Member

@vigneshshanmugam good point 👍🏼 I guess this is the reason for which Isaac decided to introduce a flag to add the filed.

Yeah was thinking the same. Got it 👍🏽

Are you aware of any implications?
Should we reach out to someone to validate?

Best we could do here would be to align with APM server as EDOT gateway would just act at its replacement.

@isaacaflores2
Copy link
Contributor Author

Have we thought about how this enrichment would work when using this processor in the EDOT gateway?

Good point @vigneshshanmugam I did not consider the use of this component running in the elastic agent in either agent or gateway mode. Is the concern that the client address may not be correct in a certain setup? I am working on open-telemetry/opentelemetry-collector#14186 which will provide more flexibility on how the client address is determined.

@gregkalapos please review and let us know if you have any concerns with the host.ip enrichment in EDOT gateway

# Conflicts:
#	processor/elasticapmprocessor/config.go
#	processor/elasticapmprocessor/processor.go
@isaacaflores2
Copy link
Contributor Author

Best we could do here would be to align with APM server as EDOT gateway would just act at its replacement.

Apologies I did not see your comment earlier. APM-Server relies on extracting the host.ip from headers and the peer address. So the work in the upstream here will provide the flexibility we need

@vigneshshanmugam
Copy link
Member

Apologies I did not see your comment earlier. APM-Server relies on extracting the host.ip from headers and the peer address. So the work in the upstream open-telemetry/opentelemetry-collector#14186 will provide the flexibility we need

Sounds good, thanks for the reference.

# Conflicts:
#	processor/elasticapmprocessor/processor.go
#	processor/elasticapmprocessor/processor_test.go
…rocessorECS`.

Removed `elastic_apm`test cases since the data_stream.dataset is asserting in the `ecs` test data
@isaacaflores2
Copy link
Contributor Author

There were a few merge conflicts with processor_test.go since other test were added in a previous PR. To handle the conflicts I did the following:

  1. Merge all the changes from main (dropping the TestProcessorECS function which was added).
  2. Add the TestProcessorECS back see commit
  3. Merged test cases from TestECSLogs and TestECSMetrics into TestProcessorECS see commit. These test cases still cover the host.ip, data_stream.dataset service routing, and host.name enrichment

Metadata: client.NewMetadata(map[string][]string{"x-elastic-mapping-mode": {"ecs"}}),
})
cfg := createDefaultConfig().(*Config)
cfg.ServiceNameInDataStreamDataset = true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] note: this is the config that was being used in the tests, note the cfg define per test case above. So all outputs included the service specific data_stream.dataset. This is why the service specific name is removed in this output file

stringValue: exec-456
- key: data_stream.dataset
value:
stringValue: apm.app.test_service
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] note: the service specific data_stream.dataset. This is expected and consolidates the test cases under the delete elastic_apm

stringValue: docker
- key: data_stream.dataset
value:
stringValue: apm.app.test_service
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] note: the service specific data_stream.dataset. This is expected and consolidates the test cases under the delete elastic_apm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants