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

Kinesis GetRecords truncates ApproximateArrivalTimestamp field #3410

Closed
3 tasks done
dacut opened this issue Jul 7, 2020 · 1 comment · Fixed by #3474 or #3479
Closed
3 tasks done

Kinesis GetRecords truncates ApproximateArrivalTimestamp field #3410

dacut opened this issue Jul 7, 2020 · 1 comment · Fixed by #3474 or #3479
Labels
bug This issue is a bug.

Comments

@dacut
Copy link

dacut commented Jul 7, 2020

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
When calling kinesis.GetRecords() for a shard, the ApproximateArrivalTimestamp field which is stored with millisecond precision per the Kinesis documentation is truncated to have zero fractional seconds. This doesn't happen for the same records with the Boto3 (Python) SDK.

Printing the ApproximateArrivalTimestamp field (to nanosecond resolution, e.g. time.Format("15:04:05.999999999")) for the Go vs Boto3 SDK yields:

Go                  Boto3
07:59:13.000000000  07:59:13.913000000
07:59:19.000000000  07:59:19.112000000
07:59:33.000000000  07:59:33.929000000
07:59:39.000000000  07:59:39.133000000
07:59:51.000000000  07:59:51.735000000
07:59:53.000000000  07:59:53.932000000
07:59:59.000000000  07:59:59.153000000
08:00:13.000000000  08:00:13.965000000
08:00:19.000000000  08:00:19.171000000
08:00:33.000000000  08:00:33.985000000
08:00:39.000000000  08:00:39.192000000
08:00:51.000000000  08:00:51.680000000
08:00:53.000000000  08:00:53.987000000
08:00:59.000000000  08:00:59.210000000

And, yes, we do need sub-second resolution for our application logs.

Version of AWS SDK for Go?
Example: v1.32.13

  • get SDK version by printing the output of aws.SDKVersion in your code after importing "github.com/aws/aws-sdk-go/aws"

Version of Go (go version)?
go version go1.14.4 darwin/amd64

To Reproduce (observed behavior)
Actual code sample:
Obtaining Kinesis records example: https://github.com/dacut/kinesis-log-watcher/blob/master/main.go#L217
And printing them: https://github.com/dacut/kinesis-log-watcher/blob/master/main.go#L247

Simplified example:

package main

import (
	"fmt"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/kinesis"
)

func main() {
	awsSession := session.Must(session.NewSession())
	kinesisClient := kinesis.New(awsSession)
	gsiInput := kinesis.GetShardIteratorInput{
		StreamName: aws.String("WebHost-development-Logs"),
		ShardId: aws.String("shardId-000000000000"),
		ShardIteratorType: aws.String("TRIM_HORIZON")
	}
	gsiOutput, _ := kinesisClient.GetShardIterator(&gsiInput)

	grInput := kinesis.GetRecordsInput{ShardIterator: gsiOutput.ShardIterator}
	for {
		grOutput, _ := kinesisClient.GetRecords(&grInput)
		for _, record := range grOutput.Records {
			ts := aws.TimeValue(record.ApproximateArrivalTimestamp)
			fmt.Printf("Timestamp=%s Nanoseconds=%d\n", ts.Format(time.RFC3339Nano), ts.Nanosecond())
		}

		if aws.Int64Value(grOutput.MillisBehindLatest) == 0 {
			break
		}

		grInput.ShardIterator = grOutput.NextShardIterator
	}
}

Expected behavior
The nanoseconds field of timestamps should be non-zero (though with only millisecond resolution).

Additional context
None.

@dacut dacut added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 7, 2020
@diehlaws diehlaws self-assigned this Aug 3, 2020
@diehlaws diehlaws removed the needs-triage This issue or PR still needs to be triaged. label Aug 3, 2020
@diehlaws
Copy link
Contributor

diehlaws commented Aug 3, 2020

Hi @dacut, thanks for bringing this to our attention and I do apologize for the delay in response on our end. I'm able to reproduce the described behavior and have brought this up with the rest of the team, we'll be investigating this behavior shortly. Once we have additional information on the matter we'll update the issue accordingly.

aws-sdk-go-automation pushed a commit that referenced this issue Aug 12, 2020
===

### Service Client Updates
* `service/cloud9`: Updates service API and documentation
  * Add ConnectionType input parameter to CreateEnvironmentEC2 endpoint. New parameter enables creation of environments with SSM connection.
* `service/comprehend`: Updates service documentation
* `service/ec2`: Updates service API and documentation
  * Introduces support for IPv6-in-IPv4 IPsec tunnels. A user can now send traffic from their on-premise IPv6 network to AWS VPCs that have IPv6 support enabled.
* `service/fsx`: Updates service API and documentation
* `service/iot`: Updates service API, documentation, and paginators
  * Audit finding suppressions: Device Defender enables customers to turn off non-compliant findings for specific resources on a per check basis.
* `service/lambda`: Updates service API and examples
  * Support for creating Lambda Functions using 'java8.al2' and 'provided.al2'
* `service/transfer`: Updates service API, documentation, and paginators
  * Adds security policies to control cryptographic algorithms advertised by your server, additional characters in usernames and length increase, and FIPS compliant endpoints in the US and Canada regions.
* `service/workspaces`: Updates service API and documentation
  * Adds optional EnableWorkDocs property to WorkspaceCreationProperties in the ModifyWorkspaceCreationProperties API

### SDK Enhancements
* `codegen`: Add XXX_Values functions for getting slice of API enums by type.
  * Fixes [#3441](#3441) by adding a new XXX_Values function for each API enum type that returns a slice of enum values, e.g `DomainStatus_Values`.
* `aws/request`: Update default retry to retry "use of closed network connection" errors ([#3476](#3476))
  * Fixes [#3406](#3406)

### SDK Bugs
* `private/protocol/json/jsonutil`: Fixes a bug that truncated millisecond precision time in API response to seconds. ([#3474](#3474))
  * Fixes [#3464](#3464)
  * Fixes [#3410](#3410)
* `codegen`: Export event stream constructor for easier mocking ([#3473](#3473))
  * Fixes [#3412](#3412) by exporting the operation's EventStream type's constructor function so it can be used to fully initialize fully when mocking out behavior for API operations with event streams.
* `service/ec2`: Fix max retries with client customizations ([#3465](#3465))
  * Fixes [#3374](#3374) by correcting the EC2 API client's customization for ModifyNetworkInterfaceAttribute and AssignPrivateIpAddresses operations to use the aws.Config.MaxRetries value if set. Previously the API client's customizations would ignore MaxRetries specified in the SDK's aws.Config.MaxRetries field.
aws-sdk-go-automation added a commit that referenced this issue Aug 12, 2020
Release v1.34.3 (2020-08-12)
===

### Service Client Updates
* `service/cloud9`: Updates service API and documentation
  * Add ConnectionType input parameter to CreateEnvironmentEC2 endpoint. New parameter enables creation of environments with SSM connection.
* `service/comprehend`: Updates service documentation
* `service/ec2`: Updates service API and documentation
  * Introduces support for IPv6-in-IPv4 IPsec tunnels. A user can now send traffic from their on-premise IPv6 network to AWS VPCs that have IPv6 support enabled.
* `service/fsx`: Updates service API and documentation
* `service/iot`: Updates service API, documentation, and paginators
  * Audit finding suppressions: Device Defender enables customers to turn off non-compliant findings for specific resources on a per check basis.
* `service/lambda`: Updates service API and examples
  * Support for creating Lambda Functions using 'java8.al2' and 'provided.al2'
* `service/transfer`: Updates service API, documentation, and paginators
  * Adds security policies to control cryptographic algorithms advertised by your server, additional characters in usernames and length increase, and FIPS compliant endpoints in the US and Canada regions.
* `service/workspaces`: Updates service API and documentation
  * Adds optional EnableWorkDocs property to WorkspaceCreationProperties in the ModifyWorkspaceCreationProperties API

### SDK Enhancements
* `codegen`: Add XXX_Values functions for getting slice of API enums by type.
  * Fixes [#3441](#3441) by adding a new XXX_Values function for each API enum type that returns a slice of enum values, e.g `DomainStatus_Values`.
* `aws/request`: Update default retry to retry "use of closed network connection" errors ([#3476](#3476))
  * Fixes [#3406](#3406)

### SDK Bugs
* `private/protocol/json/jsonutil`: Fixes a bug that truncated millisecond precision time in API response to seconds. ([#3474](#3474))
  * Fixes [#3464](#3464)
  * Fixes [#3410](#3410)
* `codegen`: Export event stream constructor for easier mocking ([#3473](#3473))
  * Fixes [#3412](#3412) by exporting the operation's EventStream type's constructor function so it can be used to fully initialize fully when mocking out behavior for API operations with event streams.
* `service/ec2`: Fix max retries with client customizations ([#3465](#3465))
  * Fixes [#3374](#3374) by correcting the EC2 API client's customization for ModifyNetworkInterfaceAttribute and AssignPrivateIpAddresses operations to use the aws.Config.MaxRetries value if set. Previously the API client's customizations would ignore MaxRetries specified in the SDK's aws.Config.MaxRetries field.
@diehlaws diehlaws removed their assignment Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
2 participants