Skip to content

Commit

Permalink
Workaround for missing function name
Browse files Browse the repository at this point in the history
The registration response is documented to include the
function name, and we rely on that. But apparently, it's blank
right now.
  • Loading branch information
Matt Whelan committed Nov 24, 2020
1 parent 0cd117b commit a33231d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lambda/extension/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (rc *RegistrationClient) Register(registrationRequest api.RegistrationReque
if err != nil {
return nil, nil, err
}
util.Debugf("Registration response: %s", bodyBytes)

var registrationResponse api.RegistrationResponse
err = json.Unmarshal(bodyBytes, &registrationResponse)
Expand Down
10 changes: 10 additions & 0 deletions telemetry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ func (c *Client) SendTelemetry(invokedFunctionARN string, telemetry [][]byte) er
logEvents = append(logEvents, logEvent)
}

if len(c.functionName) == 0 {
nameStart := strings.Index(invokedFunctionARN, ":function:") + len(":function:")
nameLen := strings.Index(invokedFunctionARN[nameStart:], ":")
if nameLen < 0 {
nameLen = len(invokedFunctionARN) - nameStart
}
c.functionName = invokedFunctionARN[nameStart:nameStart+nameLen]
util.Debugf("Recovered missing function name: %s", c.functionName)
}

compressedPayloads, err := CompressedPayloadsForLogEvents(logEvents, c.functionName, invokedFunctionARN)
if err != nil {
return err
Expand Down

0 comments on commit a33231d

Please sign in to comment.