-
Notifications
You must be signed in to change notification settings - Fork 99
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
[Streaming Telemetry 2][SNOW-899866] Enables reportKafkaPartitionStart/Usage telemetry for Streaming #694
[Streaming Telemetry 2][SNOW-899866] Enables reportKafkaPartitionStart/Usage telemetry for Streaming #694
Changes from 29 commits
0775e19
273c8d7
340d0d0
ad0a854
ec5352e
59af12c
038aa7f
ad9b223
f576c0f
92bf65f
16833c6
59786f0
1de191c
1bc3dfb
9a281a7
ba46a21
25b2220
d2c71e5
2ffa3bd
3388e25
ffa0b7b
fd9e692
fbf7719
262ecc6
766b770
0faac75
9d5943d
a47cbcf
09855b2
56dffbd
b2c036d
a951535
947b091
d8a8226
6b23cdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2023 Snowflake Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.snowflake.kafka.connector.internal.streaming.telemetry; | ||
|
||
import static com.snowflake.kafka.connector.internal.telemetry.TelemetryConstants.IS_REUSE_TABLE; | ||
import static com.snowflake.kafka.connector.internal.telemetry.TelemetryConstants.Streaming.TP_CHANNEL_CREATION_TIME; | ||
import static com.snowflake.kafka.connector.internal.telemetry.TelemetryConstants.Streaming.TP_CHANNEL_NAME; | ||
import static com.snowflake.kafka.connector.internal.telemetry.TelemetryConstants.TABLE_NAME; | ||
|
||
import com.snowflake.kafka.connector.internal.telemetry.SnowflakeTelemetryBasicInfo; | ||
import com.snowflake.kafka.connector.internal.telemetry.SnowflakeTelemetryService; | ||
import net.snowflake.client.jdbc.internal.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
/** | ||
* This object is sent only once when a channel starts. No concurrent modification is made on this | ||
* object, thus no lock is required. | ||
*/ | ||
public class SnowflakeTelemetryChannelCreation extends SnowflakeTelemetryBasicInfo { | ||
private final long tpChannelCreationTime; // start time of the channel | ||
private final String tpChannelName; | ||
private boolean isReuseTable = false; // is the channel reusing existing table | ||
sfc-gh-rcheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public SnowflakeTelemetryChannelCreation( | ||
final String tableName, final String channelName, final long startTime) { | ||
super(tableName, SnowflakeTelemetryService.TelemetryType.KAFKA_CHANNEL_START); | ||
this.tpChannelName = channelName; | ||
this.tpChannelCreationTime = startTime; | ||
} | ||
|
||
@Override | ||
public void dumpTo(ObjectNode msg) { | ||
msg.put(TABLE_NAME, this.tableName); | ||
msg.put(TP_CHANNEL_NAME, this.tpChannelName); | ||
|
||
msg.put(IS_REUSE_TABLE, this.isReuseTable); | ||
msg.put(TP_CHANNEL_CREATION_TIME, tpChannelCreationTime); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
throw new IllegalStateException( | ||
"Empty function doesnt apply to:" + this.getClass().getSimpleName()); | ||
} | ||
|
||
public void setReuseTable(boolean reuseTable) { | ||
isReuseTable = reuseTable; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,12 +15,14 @@ | |
* under the License. | ||
*/ | ||
|
||
package com.snowflake.kafka.connector.internal.streaming; | ||
package com.snowflake.kafka.connector.internal.streaming.telemetry; | ||
|
||
import com.snowflake.kafka.connector.internal.telemetry.SnowflakeTelemetryBasicInfo; | ||
import com.google.common.annotations.VisibleForTesting; | ||
import com.snowflake.kafka.connector.internal.streaming.IngestionMethodConfig; | ||
import com.snowflake.kafka.connector.internal.telemetry.SnowflakeTelemetryService; | ||
import java.sql.Connection; | ||
import net.snowflake.client.jdbc.internal.fasterxml.jackson.databind.node.ObjectNode; | ||
import net.snowflake.client.jdbc.telemetry.Telemetry; | ||
import net.snowflake.client.jdbc.telemetry.TelemetryClient; | ||
|
||
/** | ||
|
@@ -38,10 +40,9 @@ public SnowflakeTelemetryServiceV2(Connection conn) { | |
this.telemetry = TelemetryClient.createTelemetry(conn); | ||
} | ||
|
||
@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved reportKafkaPartitionUsage to the parent SnowflakeTelemetryService |
||
public void reportKafkaPartitionUsage( | ||
SnowflakeTelemetryBasicInfo partitionStatus, boolean isClosing) { | ||
throw new IllegalStateException("Snowpipe Streaming Doesnt Have Pipe Usage"); | ||
@VisibleForTesting | ||
public SnowflakeTelemetryServiceV2(Telemetry telemetry) { | ||
this.telemetry = telemetry; | ||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,19 +7,22 @@ | |
|
||
/** Minimum information needed to sent to Snowflake through Telemetry API */ | ||
public abstract class SnowflakeTelemetryBasicInfo { | ||
final String tableName; | ||
public final String tableName; | ||
public final SnowflakeTelemetryService.TelemetryType telemetryType; | ||
|
||
static final KCLogger LOGGER = new KCLogger(SnowflakeTelemetryBasicInfo.class.getName()); | ||
public static final KCLogger LOGGER = new KCLogger(SnowflakeTelemetryBasicInfo.class.getName()); | ||
|
||
/** | ||
* Base Constructor. Accepts a tableName and StageName. | ||
* | ||
* @param tableName Checks for Nullability | ||
*/ | ||
public SnowflakeTelemetryBasicInfo(final String tableName) { | ||
public SnowflakeTelemetryBasicInfo( | ||
final String tableName, SnowflakeTelemetryService.TelemetryType telemetryType) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass telemetry type here to simplify reportKafkaPartitionUsage/Creation code paths across snowpipe and streaming |
||
Preconditions.checkArgument( | ||
!Strings.isNullOrEmpty(tableName), "tableName cannot be null or empty"); | ||
this.tableName = tableName; | ||
this.telemetryType = telemetryType; | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we send this somewhere periodically instead of just during close?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be ideal, but currently we don't have anything running periodically in the background. InsertRows is an option, but I'm worried about overloading the telemetry service since we have no control over how often the customer flushes their buffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it something we plan to add in the future? I think we send the usage for Snowpipe periodically. Otherwise I feel like this is not very useful since there're no usage reported if there is no open/close on the channel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not have any plans to add that in the future. It could potentially be a part of the flush service.
Currently we not periodically send Snowpipe usage.
reportKafkaPartition(
) is called on on close and when the cleaner runs, which only runs on the first insert to initialize a pipe