question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Adding Metric attribute always results in error.

See original GitHub issue

Expected Behaviour

A metric viewable in Cloudwatch

Current Behaviour

Lambda will start and go a few lines into the function handler. We are able to inject the dynamodb connections. And possibly around the first call to DynamoDB it goes like this, but it is not clear what is needed to fix this.

fail System.InvalidOperationException: Unable to determine range key from index name at AWS.Lambda.Powertools.Metrics.MetricsAspectHandler.OnException[T](AspectEventArgs eventArgs, Exception exception)

Code snippet

[Metrics(Namespace = "nl.my.namespace", Service = "Print", RaiseOnEmptyMetrics = false, CaptureColdStart = true)]
    public async Task<PrintResponse> FunctionHandlerAsync(PrintRequest input, ILambdaContext context)

Possible Solution

Adding the correct attributes in the models for the Object persistence model we have implemented. Even the ones we do not use. If that works I will update this bugreport.

Steps to Reproduce

Add the metric attribute to a Function handler.

[Metrics(Namespace = “nl.my.namespace”, Service = “Print”, RaiseOnEmptyMetrics = false, CaptureColdStart = true)]

AWS Lambda Powertools for .NET version

1.2.0

AWS Lambda function runtime

dotnet6

Debugging logs

fail	System.InvalidOperationException: Unable to determine range key from index name
   at AWS.Lambda.Powertools.Metrics.MetricsAspectHandler.OnException[T](AspectEventArgs eventArgs, Exception exception)
   at AWS.Lambda.Powertools.Common.MethodAspectAttribute.WrapAsync[T](Func`2 target, Object[] args, AspectEventArgs eventArgs)
   at lambda_method1(Closure , Stream , ILambdaContext , Stream )
   at Amazon.Lambda.RuntimeSupport.Bootstrap.UserCodeLoader.Invoke(Stream lambdaData, ILambdaContext lambdaContext, Stream outStream) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/UserCodeLoader.cs:line 145
   at Amazon.Lambda.RuntimeSupport.HandlerWrapper.<>c__DisplayClass8_0.<GetHandlerWrapper>b__0(InvocationRequest invocation) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/HandlerWrapper.cs:line 55
   at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken) in /src/Repo/Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/LambdaBootstrap.cs:line 176

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hjgracacommented, Jun 5, 2023

Closing this issue. This issue might have highlighted the need to expose stack trace from the originating exception if there is no exception handling and it cascades to the handler and is caught by Powertools. Will discuss in opening an issue for that.

1reaction
roelvandenbrandcommented, May 31, 2023

Yes, sorry for the late reply. With the fix in my dynamodb component that error disappeared. But still, an underlying error was mostly obscured by the powertools handling of the error. I am going to test it again soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OTLP gRPC exporter giving error while sending lots of ...
I am getting this error only if I increase the number of attributes and instrument 3 metrics together. I am not receiving any...
Read more >
870446 – multi operations with attribute manipulation not ...
Description of problem: When doing a multioperation --addattr and --delattr on an attribute that is single valued and required, no error message is...
Read more >
Metrics defined on both attributes and facts cause error in ...
Before MicroStrategy 2020, metrics defined on both attributes and facts are regarded only as metrics defined on attributes, and a derived ...
Read more >
Troubleshooting the OpenTelemetry Collector
When neither metric are showing that data points have been seen, it's an indication that the Collector hasn't received the data point at...
Read more >
Error Message on indexer console
I'm seeing the error below under messages in my Splunk enterprise console: Missing or malformed ... message = Failed to add new result....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found