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 Micrometer integration #2445

Open
patpatpat123 opened this issue Feb 6, 2023 · 10 comments
Open

Add Micrometer integration #2445

patpatpat123 opened this issue Feb 6, 2023 · 10 comments
Labels
type: enhancement A general enhancement

Comments

@patpatpat123
Copy link

Hello Spring Data Elasticsearch team,

Wanted to start a small issue regarding a SpringBoot app, which has micrometer + actuator + Spring Data Elasticsearch please.

This issue is based on the very recent talk at SpringOne regarding Spring Data: https://springone.io/sessions/modern-persistence-with-spring-data-3 (very cool talk btw)

As you can see at 21:00 (please see screenshot), it is mentioned the Spring Data projects which are integrated with observability. Unfortunately, Elasticsearch is not present.

Screenshot_20230206_055330

In order to confirm that, we have a SpringBoot app which is storing / retrieving data from Cassandra, and indeed, in our Zipkin, we could see the database interactions.

However, a similar app, where the data source is Elasticsearch, we are able to see the traces, but traces are without the interaction with Elasticsearch.

May I ask how to enable the traces with Elasticsearch please?

Thank you

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 6, 2023
@sothawo sothawo removed the status: waiting-for-triage An issue we've not yet triaged label Feb 6, 2023
@sothawo
Copy link
Collaborator

sothawo commented Feb 6, 2023

There currently is no support implemented in Spring Data Elasticsearch for that.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 6, 2023
@patpatpat123
Copy link
Author

Thank you @sothawo for the clear explanation.

May I ask if it is possible to take this as enhancement, improvement request please?

@sothawo sothawo changed the title SpringBoot 3 + Spring Data Elasticsearch + Micrometer integration, no traces for Elasticsearch Add Micrometer integration Feb 6, 2023
@sothawo sothawo added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 6, 2023
@davidmelia
Copy link

@sothawo I'm also interested in this and can see the other Spring Data projects have support for this:

even a section in the spring data elastic reference on how we can override the auto configuration would be beneficial.

Thanks

@sothawo
Copy link
Collaborator

sothawo commented Mar 14, 2023

As I wrote, there is no support currently in Spring Data Elasticsearch in regards to this observability topic.

In contrast to Spring Data Mongodb a Spring Data Elasticsearch is a community driven project, there is no dedicated team anywhere working on it. So this issue will be open until either a contribution from the community adds support for observability or I find time to add this. But I am doing this work in my spare time, so I can't tell when I will find to address this issue.

@patpatpat123
Copy link
Author

Just wanted to take the time to say thanks to @sothawo.
I am a heavy user a spring data reactive elasticsearch and this repo makes things much easier.

I do not have the level of a contributor, but if you believe you can leave some pointers here, happy to try to come up with a PR.
Regardless, looking forward to seeing this!

@davidmelia
Copy link

Hi, as an FYI this is the solution I found to add observation to Spring Data Elastic Reactive

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.httpcomponents.MicrometerHttpClientInterceptor;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClientBuilder;
import org.springframework.boot.autoconfigure.elasticsearch.RestClientBuilderCustomizer;
import org.springframework.context.annotation.Bean;

  @Bean
  RestClientBuilderCustomizer elasticSearchMetricsrestClientBuilderCustomizer(MeterRegistry registry) {

    return new RestClientBuilderCustomizer() {
    
    @Override
    public void customize(HttpAsyncClientBuilder builder) {
        MicrometerHttpClientInterceptor interceptor = new MicrometerHttpClientInterceptor(registry,
                  request -> request.getRequestLine().getUri(),
                  Tags.empty(),
                 true);
      builder.addInterceptorFirst(interceptor.getRequestInterceptor());
      builder.addInterceptorLast(interceptor.getResponseInterceptor());
    }

    @Override
    public void customize(RestClientBuilder builder) {
      // TODO Auto-generated method stub
      
    }
  };
  }

@sothawo
Copy link
Collaborator

sothawo commented May 4, 2023

import org.springframework.boot.autoconfigure.elasticsearch.RestClientBuilderCustomizer;

Adding this to Spring Data Elasticsearch would add a dependency on Spring Boot, which we cannnot do (it would create a circular dependency).

@patpatpat123
Copy link
Author

Is this possible to break the circular dependency with some other mechanism? (reflection, etc...)

Metrics and traces are quite baseline features for any production workload and having those in this project would be a great plus

@piotrooo
Copy link

piotrooo commented Jul 3, 2024

That's a HUGE functionality gap since Elasticsearch in Spring Data is widely used. And that's one of the deal breakers for using the OpenTelemetry JavaAagent instead of Micrometer.

cc: @marcingrzejszczak

@sothawo
Copy link
Collaborator

sothawo commented Jul 3, 2024

As I already wrote:

Spring Data Elasticsearch is a community driven project, there is no dedicated team anywhere working on it. So this issue will be open until either a contribution from the community adds support for observability or I find time to add this. But I am doing this work in my spare time, so I can't tell when I will find to address this issue.

I have a day time job, a family and some other hobbies and interests beside this project. Contributions are always welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants