-
Notifications
You must be signed in to change notification settings - Fork 44
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
docs: update onboarding steps for Go v3 client #6987
base: master
Are you sure you want to change the base?
Conversation
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.
From my point of view, this looks good, and along with the new API for the client. Great job! 👍
I've decided to go ahead with changes only to GO and will update Java onboarding in another branch. I'd rather we get this part of the UI updated ASAP instead of possibly having it held until January because of 1) Christmas Holidays 2) Unexpected obstacles in updating onboarding for Java. BTW. Not sure what to do about the
|
Hi @karel-rehor, sorry for the delay on this - I was working on fixing the CI pipeline and I see it has passed the tests now. I'll take a look at this PR in more detail tomorrow. Thank you! |
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.
Hello! Thanks for doing this! I apologize for not getting to this when I said I would, it slipped my mind completely. Similar to the Java onboarding, it would be helpful for a video demonstrating the changes since I noticed some spacing and formatting changes, but it looks good to me otherwise! If the video size limit is an issue here, let me know and I can run the branch locally to see these changes
@@ -48,7 +48,8 @@ export const WriteDataComponent = (props: OwnProps) => { | |||
onSelectBucket(bucket.name) | |||
}, [bucket, onSelectBucket]) | |||
|
|||
const codeSnippet = `org := "${org.name}" | |||
const codeSnippet = `// FOO |
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.
I see the // FOO
line is the only thing changed here, is that for consistency?
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.
This was removed
"count": 40, | ||
}, | ||
} | ||
const writeCodeSnippet = ` data := map[string]map[string]interface{}{ |
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.
Curious to see what effect this whitespace has on the snippet
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.
The instruction is to add this snippet at the end of the main()
function in a previous snippet. All together this renders as...
func main() {
// Create client
url := "http://localhost:8080"
token := os.Getenv("INFLUXDB_TOKEN")
// Create a new client using an InfluxDB server base URL and an authentication token
client, err := influxdb3.New(influxdb3.ClientConfig{
Host: url,
Token: token,
})
if err != nil {
panic(err)
}
// Close client at the end and escalate error if present
defer func (client *influxdb3.Client) {
err := client.Close()
if err != nil {
panic(err)
}
}(client)
database := "my-bucket"
data := map[string]map[string]interface{}{
"point1": {
"location": "Klamath",
"species": "bees",
"count": 23,
},
"point2": {
"location": "Portland",
"species": "ants",
"count": 30,
},
"point3": {
"location": "Klamath",
"species": "bees",
"count": 28,
},
"point4": {
"location": "Portland",
"species": "ants",
"count": 32,
},
"point5": {
"location": "Klamath",
"species": "bees",
"count": 29,
},
"point6": {
"location": "Portland",
"species": "ants",
"count": 40,
},
}
// convert data to Points
points := []*influxdb3.Point{}
// start time stamp
stamp := time.Now().Add(time.Duration(len(data)) * time.Second * -1)
for key := range data {
points = append(points,
influxdb3.NewPointWithMeasurement("census").
SetTag("location", data[key]["location"].(string)).
SetIntegerField(data[key]["species"].(string),
int64(data[key]["count"].(int))).
SetTimestamp(stamp))
stamp = stamp.Add(time.Second) // Add a second to the stamp
}
// Write data
fmt.Printf("Writing %d points\n", len(points))
if err := client.WritePoints(context.Background(),
points,
influxdb3.WithDatabase(database)); err != nil {
panic(err)
}
}
panic(err) | ||
} | ||
if err != nil { | ||
panic(err) |
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.
Also curious about the whitespace here, looks like the number of spaces in a tab has changed, is that maintained across all snippets in the go onboarding?
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.
Here is the main()
method with all copy-pasted snippets.
func main() {
// Create client
url := "http://localhost:8080"
token := os.Getenv("INFLUXDB_TOKEN")
// Create a new client using an InfluxDB server base URL and an authentication token
client, err := influxdb3.New(influxdb3.ClientConfig{
Host: url,
Token: token,
})
if err != nil {
panic(err)
}
// Close client at the end and escalate error if present
defer func (client *influxdb3.Client) {
err := client.Close()
if err != nil {
panic(err)
}
}(client)
database := "my-bucket"
data := map[string]map[string]interface{}{
"point1": {
"location": "Klamath",
"species": "bees",
"count": 23,
},
"point2": {
"location": "Portland",
"species": "ants",
"count": 30,
},
"point3": {
"location": "Klamath",
"species": "bees",
"count": 28,
},
"point4": {
"location": "Portland",
"species": "ants",
"count": 32,
},
"point5": {
"location": "Klamath",
"species": "bees",
"count": 29,
},
"point6": {
"location": "Portland",
"species": "ants",
"count": 40,
},
}
// convert data to Points
points := []*influxdb3.Point{}
// start time stamp
stamp := time.Now().Add(time.Duration(len(data)) * time.Second * -1)
for key := range data {
points = append(points,
influxdb3.NewPointWithMeasurement("census").
SetTag("location", data[key]["location"].(string)).
SetIntegerField(data[key]["species"].(string),
int64(data[key]["count"].(int))).
SetTimestamp(stamp))
stamp = stamp.Add(time.Second) // Add a second to the stamp
}
// Write data
fmt.Printf("Writing %d points\n", len(points))
if err := client.WritePoints(context.Background(),
points,
influxdb3.WithDatabase(database)); err != nil {
panic(err)
}
// Execute query with parameters
query := `SELECT *
FROM 'census'
WHERE time >= now() - interval '1 hour'
AND ($species1 IS NOT NULL OR $species2 IS NOT NULL)`
iterator, err := client.QueryWithParameters(context.Background(),
query, influxdb3.QueryParameters{
"species1": "bees",
"species2": "ants",
},
influxdb3.WithDatabase(database))
if err != nil {
panic(err)
}
val2int := func(v interface{}) int64 {
if v == nil {
return 0
}
return v.(int64)
}
for iterator.Next() {
value := iterator.Value()
location := value["location"]
ants := val2int(value["ants"])
bees := val2int(value["bees"])
ts := value["time"].(time.Time)
fmt.Printf("At %s in %s there were %d ants and %d bees\n",
ts.Format(time.RFC3339), location, ants, bees)
}
}
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.
Hi @karel-rehor - thanks for doing this. This looks good based on my review, as long as the rationale for doing this is the same as in the Go PR: i.e., this is just to update to conform to changes to the influxdb v3 client libraries.
Before we approve this to merge in, could you please add a video confirming we don't end up with any visual artifacts here? Thanks very much.
Here is a screen cast of the workflow for this on-boarding update. Not shown is pasting code samples to an IDE, or waiting for response after running writes. Screencast.from.30-01-25.13.58.10.webm |
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.
This looks good to me now - thanks for posting the video. I noted here #6994 that we need to wait for a moment on an internal fix to our CI pipeline - I will ping you once it has been cleared up.
Hi @karel-rehor - you should be able to rebase / repush and attempt to merge now. |
Hi @karel-rehor - checking in to see if you are good to rebase and merge this - thank you. |
47708df
to
d7e3515
Compare
@wdoconnell |
@wdconnell If you could once more give this your review - I removed a commented line in a code snippet caught by @david-rusnak - I think this can be merged. |
@karel-rehor - Looks good to merge, feel free to do so. Thank you for updating! |
More flake occurred. Going to retry this on Monday a.m., as it's late here. We should be able to pass CI as it was in good condition for #7000. I will give it a look first thing in the am. |
Getting flake on the scriptQueryBuilder test. We may need to revisit that if it keeps causing issues like this. |
* docs: update go-client v3 onboarding steps to reflect v2.0.0 release * chore: ran prettier:fix * chore: remove stale test comment
@karel-rehor Looking at the cause of the e2e failure I think the interim solution will need to be disabling this flaking test. #7020. I have opened an internal issue to have someone allocate time to have a closer look at the root causes so that the relevant test can be re-enabled. You will need to rebase once #7020 is merged. |
5ed8e0e
to
1b6c45b
Compare
I have handled the rebase - will add it back to the merge queue now. |
1b6c45b
to
ccaae67
Compare
ccaae67
to
6223bb8
Compare
Updates the onboarding steps for Go v3 client
Checklist
Authors and Reviewer(s), please verify the following: