newrelic / micrometer-registry-newrelic

ARCHIVED. TO SEND MICROMETER METRICS TO NEW RELIC, FOLLOW THE DIRECTION IN THE README.md. Micrometer registry implementation that sends data to New Relic as dimensional metrics.
Apache License 2.0
35 stars 19 forks source link

usage info #97

Closed gyoga99 closed 4 years ago

gyoga99 commented 4 years ago

Can this library be used in aws lambda for java?

jeffalder commented 4 years ago

@gyoga99 Potentially; however, it's not recommended given the fairly short lifetime of most Lambdas. Have you looked into our OpenTracing Tracer for Lambdas?

https://github.com/newrelic/java-aws-lambda https://github.com/newrelic/newrelic-lambda-tracer-java

gyoga99 commented 4 years ago

@jeffalder Thanks for your response! I am looking for sending custom metrics to Metrics API from java lambda code in an asynchronous manner. Does "OpenTracing Tracer for Lambdas" support that?

jeffalder commented 4 years ago

Ah, Metrics. No, no metrics from either tool. This registry is useful for metrics. You'll have to ensure that your lambda stays running long enough to send the metrics, and that it shuts down afterwards; otherwise you could lose vital data.

MattWhelan commented 4 years ago

It's worth noting that the AWS Lambda platform doesn't really support asynchronous activity. The process doesn't get scheduled on the CPU unless it's processing an invocation event, so from the perspective of the process, time stops between invocations, sometimes for many minutes. Further, the Lambda service may decide to terminate the container at any time, without notifying the handler process, or giving it any CPU time.

Just poof.

So the normal metric cycle where we report [set of statistics] every [period] can't work reliably in Lambda, due to the platform's limitations. Instead, our Lambda monitoring sends the data outside of the function's container on every invocation. In a world like that, it's probably better to just add custom attributes to your spans, and do the aggregation using either Events to Metrics, or just in a NRQL query.

breedx-nr commented 4 years ago

@gyoga99 Hi. I think @MattWhelan and @jeffalder kinda covered this for ya. I have done some scratching around to see if we could offer a simple solution to the desire to generate custom metrics from your lambda...unfortunately there isn't a simple/straightfoward way right now.

The most viable idea right now is to leverage the opentracing libraries that @jeffalder linked above to generate custom EVENTS. I know this isn't what you asked for, but maybe it can get you close enough? Please feel free to reopen this if you'd like to continue the conversation. 👍